//
//  TestAFViewController.m
//  HYSmileiOS
//
//  Created by SMC-MAC on 16/4/26.
//  Copyright © 2016年 heyou. All rights reserved.
//

/**
 *  定义测试功能名称
 */

#define AF_GET      @"AF_GET"
#define AF_POST     @"AF_POST"

#import "TestAFViewController.h"
#import "heyou.h"
//#import "UserInfoBrief.h"
#import "HttpProvider.h"

@interface TestAFViewController ()
{
    NSArray<NSString*> *_modules;
}

@end

@implementation TestAFViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self prepareData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark -- prepare data
- (void)prepareData {
    _modules = @[AF_GET, AF_POST];
}

#pragma mark -- test functions
- (void)testGet {
    NSLog(@"%s", __FUNCTION__);
    
    UserInfoBrief *info = [UserInfoBrief new];
//    info.mid = @"123456";
//    info.name = @"alekye";
    info.from = 1;
    
    [HttpProvider getUserDetailInfo:info success:^(UserInfoDetail *detail) {
        NSLog(@"get detail ok");
    } failure:^(NSError *error) {
        
    }];
}

- (void)testPost {
    NSLog(@"%s", __FUNCTION__);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _modules.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString* testCell = @"testCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:testCell];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:testCell];
    }
    
    // Configure the cell...
    cell.textLabel.text = [_modules objectAtIndex:indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
    NSString *moduleName = [_modules objectAtIndex:indexPath.row];
    if ([moduleName isEqualToString:AF_GET]) {
        [self testGet];
    } else if ([moduleName isEqualToString:AF_POST]) {
        [self testPost];
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
